package com.qf.device.controller;


import com.qf.core.dto.PageDto;
import com.qf.core.vo.PageResult;
import com.qf.core.vo.R;


import com.qf.device.dto.DeviceTypePageDto;
import com.qf.device.entity.DeviceType;
import com.qf.device.service.DeviceTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 设备类型表 前端控制器
 * </p>
 *
 * @author zhu
 * @since 2023-10-26
 */
@RestController
@CrossOrigin
@RequestMapping("/device-type")
public class DeviceTypeController {

    @Autowired
    private DeviceTypeService deviceTypeService;

    @GetMapping("/list")
    public R<List<DeviceType>> list() {
        return new R<List<DeviceType>>(true, 0, "查询成功", deviceTypeService.list());
    }

    @PostMapping("add")
    public R add(@RequestBody DeviceType deviceType){
        return deviceTypeService.add(deviceType);
    }

    @PostMapping("page")
    public PageResult page(@RequestBody PageDto<DeviceTypePageDto> deviceTypePageDto){
        return deviceTypeService.page(deviceTypePageDto);
    }

    @PostMapping("update")
    public R update(@RequestBody DeviceType deviceType){
        return deviceTypeService.update(deviceType);
    }

    @PostMapping("delete/{id}")
    public R delete(@PathVariable String id){

        return deviceTypeService.deleteDeviceType(id);
    }



}
